package com.njaccp.countword;

import java.util.ArrayList;
import java.util.HashMap;

public class WordCountThread extends Thread {
    private ArrayList<String> allWordList;
    private String key;
    private HashMap<String,Integer> wordCountMap=null;
    public WordCountThread() {
    }

    public WordCountThread(ArrayList<String> allWordList, String key, HashMap<String, Integer> wordCountMap) {
        this.allWordList = allWordList;
        this.key = key;
        this.wordCountMap = wordCountMap;
    }

    @Override
    public void run() {
        int count=0;

            for (int i = 0; i < allWordList.size(); i++) {
                if (allWordList.get(i).equals(key)) {
                    count++;
                }
            }

        wordCountMap.put(key,count);
    }
}
